/*
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
 * in compliance with the License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
 * or implied. See the License for the specific language governing permissions and limitations under
 * the License.
 *
 * Copyright @2008 the original author or authors.
 */
package com.bluestone.report;

import java.beans.PropertyChangeEvent;


/**
 * TestCaseReportBean records some informations for the TestCase.
 * @author <a href="mailto:ming7655@gmail.com">Aaron</a>
 */
public class TestCaseReportBean extends AbstractReportBean {
	/**
	 * 
	 */
	private static final long serialVersionUID = 3022866025973363152L;
	private String testCaseId;
	private String testCaseAttributeId;
	private String testCaseName;
	private String testCaseExecuteResult = "true";
	private int reTryCount = 0;

	public String getTestCaseAttributeId() {
		return testCaseAttributeId;
	}
	public void setTestCaseAttributeId(String testCaseAttributeId) {
		this.testCaseAttributeId = testCaseAttributeId;
	}
	public String getTestCaseId() {
		return testCaseId;
	}
	public void setTestCaseId(String testCaseId) {
		this.testCaseId = testCaseId;
	}
	public String getTestCaseName() {
		return testCaseName;
	}
	public void setTestCaseName(String testCaseName) {
		this.testCaseName = testCaseName;
	}
	public void propertyChange(PropertyChangeEvent evt) {
		super.propertyChange(evt);
		String propertyName = evt.getPropertyName();
		if(PropertyAwareObject.PROPERTY_EXECUTERESULT.equals(propertyName)){
			Object value = evt.getNewValue();
			Object source =evt.getSource();
			if("false".equals(value)&&CommandReportBean.class.isInstance(source)){
				this.setTestCaseExecuteResult("false");
				this.setReTryCount(reTryCount+1);
			}
		}
		
	}
	public String getTestCaseExecuteResult() {
		return testCaseExecuteResult;
	}
	public void setTestCaseExecuteResult(String testCaseExecuteResult) {
		this.testCaseExecuteResult = testCaseExecuteResult;
		
	}
	public int getReTryCount() {
		return reTryCount;
	}
	public void setReTryCount(int reTryCount) {
		this.reTryCount = reTryCount;
		this.firePropertyChange(PROPERTY_EXECUTERESULT, null, String.valueOf(reTryCount));
	}
}
